package com.heima.media.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.media.dto.NewsAuthDto;
import com.heima.media.dto.NewsDto;
import com.heima.media.dto.WmNewsDto;
import com.heima.media.dto.WmNewsPageDto;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.heima.media.service.IWmNewsService;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 自媒体图文内容信息表 前端控制器
 * </p>
 *
 * @author mcm
 * @since 2022-06-21
 */
@RestController
@RequestMapping("/api/v1/news")
@Api(tags = "自媒体图文内容信息表接口")
public class WmNewsController{

    @Autowired
    private IWmNewsService wmNewsService;

//    媒体审核的分液查询
    @PostMapping("/findPageByName")
    public ResponseResult findPageByName(@RequestBody NewsDto newsDto){
        System.out.println("------------------------------------------------->"+newsDto.getPage());
        return wmNewsService.findPageByName(newsDto);


    }
    @GetMapping("/findNewsVoById/{id}")
    public ResponseResult findNewsVoById(@PathVariable Integer id){

        return wmNewsService.listById(id);

    }
//    内容列表查询
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageDto newsDto){
        return wmNewsService.find(newsDto);

    }
//    文章的添加
    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto dto) {
    return wmNewsService.submit(dto);
}

//根据id查询文章
    @GetMapping("/{id}")
    public ResponseResult listNewsById(@PathVariable Integer id){
        return wmNewsService.listById(id);
    }
//    文章的上下架
    @PostMapping ("/down_or_up")
    public ResponseResult changeEnable(@RequestBody WmNewsDto dto){
        return wmNewsService.changeEnable(dto);

    }
//   人工审核失败
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return wmNewsService.auth(dto,0);
    }
//    人工审核成功
    @PostMapping("/auth_pass")
    public  ResponseResult authPass(@RequestBody NewsAuthDto dto){
        return wmNewsService.auth(dto,1);

    }




}


